<template>
  <h1>El-菜单组件</h1>
  <el-menu mode="horizontal"
           background-color="#4F8DFE" text-color="#fff"
           default-active="3" active-text-color="#ff0" @select="handleSelect">
    <el-menu-item index="1">首页</el-menu-item>
    <el-menu-item index="2">免费课</el-menu-item>
    <el-menu-item index="3">直播课</el-menu-item>
    <el-menu-item index="4">精品课</el-menu-item>
    <el-menu-item index="5">线上班</el-menu-item>
    <el-sub-menu index="6">
      <template #title>线下班</template>
      <el-menu-item index="6-1">JSDTN2411</el-menu-item>
      <el-menu-item index="6-2">JSDTN2412</el-menu-item>
      <el-menu-item index="6-3">JSDTN2502</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<script setup>
// @select="handleSelect" 是菜单上的选择事件,只要选择了某个菜单项,就会立即执行
//且能获取到下面两个值:
// index:当前选中的菜单项的index值
// indexPath:如何找到此菜单项的路径,比如:["6","6-1"]
const handleSelect = (index, indexPath) => {
  console.log(index, indexPath);
}
</script>

<style scoped>

</style>